package com.indeep.user.constant;

import com.indeep.user.emun.Levels;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class LevelAndExp {
    // 等级
    private Levels level;
    // 总经验
    private Integer totalExp;
    
    public LevelAndExp(Integer exp) {
        if (exp < 0) return;
        this.totalExp = exp / 1000;
        for (Levels value : Levels.values()) {
            if (totalExp >= value.minExp && totalExp <= value.maxExp) {
                this.level = value;
                break;
            }
        }
    }
    
    
}
